package com.qwer.controller.comm;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.qwer.model.comm.UserInfo;
import com.qwer.service.comm.UserService;

@Controller
@RequestMapping("/login")
public class LoginController {
    
    @Autowired
    private UserService userService;
    
    
    @RequestMapping(value = { "/check"})
    @ResponseBody
    public String zpIndex(Map<String, Object> model,UserInfo info,HttpServletRequest req,HttpServletResponse resp,HttpSession session) {
        UserInfo sysUser = userService.login(info);
        session.setAttribute("sysUser", sysUser);
        return JSON.toJSONString(sysUser);
    }
    
    @RequestMapping(value = {"/loginOut" })
    public String login(Map<String, Object> model,HttpServletRequest req,HttpSession session) {
    	session.removeAttribute("sysUser");
        return "login";
    }
    
    
}
